package com.bjsxt.mapper;

import com.bjsxt.pojo.Menu;
import com.bjsxt.pojo.TreeA;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MenuMapper {

    //查询指定角色下菜单
    @Select("SELECT  *  FROM   t_menu   WHERE  MID  IN  (SELECT  MID  FROM  t_role_menu WHERE  rid  IN(SELECT  rid   FROM   t_admin_role  WHERE  aid=#{param1}))  AND  pid=#{param2}")
    List<Menu>   selectMore(Integer aid,Integer pid);

    @Select("select *  from t_menu")
    List<Menu>   selectAll();

    @Select("SELECT  *  FROM  t_menu  WHERE  pid=#{param1}")
    List<Menu>  selectAll2(Integer pid);

    //添加菜单实现
    @Insert("insert into   t_menu(mname,pid,status,url,mdesc) values(#{mname},#{pid},#{status},#{url},#{mdesc})")
    Integer   insert(Menu menu);

    //修改菜单实现
    @Update("update t_menu  set mname=#{mname},pid=#{pid},status=#{status},url=#{url},mdesc=#{mdesc} where mid=#{mid}")
    Integer   update(Menu menu);

    //删除菜单实现
    @Delete("delete from t_menu where mid=#{param1} ")
    Integer   delete(Integer mid);

    List<TreeA>  selectAll3(Integer pid);


}
